package com.ruoyi.system.controller;

import java.util.List;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.system.domain.QMytongji;
import com.ruoyi.system.service.IQMytongjiService;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 客服不满意率统计Controller
 * 
 * @author ruoyi
 * @date 2024-07-17
 */
@Controller
@RequestMapping("/system/mytongji")
public class QMytongjiController extends BaseController
{
    private String prefix = "system/mytongji";

    @Autowired
    private IQMytongjiService qMytongjiService;

    @RequiresPermissions("system:mytongji:view")
    @GetMapping()
    public String mytongji()
    {
        return prefix + "/mytongji";
    }

    /**
     * 查询客服不满意率统计列表
     */
    @RequiresPermissions("system:mytongji:list")
    @PostMapping("/list")
    @ResponseBody
    public TableDataInfo list(QMytongji qMytongji)
    {
        startPage();
        List<QMytongji> list = qMytongjiService.selectQMytongjiList(qMytongji);
        return getDataTable(list);
    }

    /**
     * 导出客服不满意率统计列表
     */
    @RequiresPermissions("system:mytongji:export")
    @Log(title = "客服不满意率统计", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    @ResponseBody
    public AjaxResult export(QMytongji qMytongji)
    {
        List<QMytongji> list = qMytongjiService.selectQMytongjiList(qMytongji);
        ExcelUtil<QMytongji> util = new ExcelUtil<QMytongji>(QMytongji.class);
        return util.exportExcel(list, "客服不满意率统计数据");
    }

    /**
     * 新增客服不满意率统计
     */
    @GetMapping("/add")
    public String add()
    {
        return prefix + "/add";
    }

    /**
     * 新增保存客服不满意率统计
     */
    @RequiresPermissions("system:mytongji:add")
    @Log(title = "客服不满意率统计", businessType = BusinessType.INSERT)
    @PostMapping("/add")
    @ResponseBody
    public AjaxResult addSave(QMytongji qMytongji)
    {
        return toAjax(qMytongjiService.insertQMytongji(qMytongji));
    }

    /**
     * 修改客服不满意率统计
     */
    @RequiresPermissions("system:mytongji:edit")
    @GetMapping("/edit/{myid}")
    public String edit(@PathVariable("myid") Long myid, ModelMap mmap)
    {
        QMytongji qMytongji = qMytongjiService.selectQMytongjiByMyid(myid);
        mmap.put("qMytongji", qMytongji);
        return prefix + "/edit";
    }

    /**
     * 修改保存客服不满意率统计
     */
    @RequiresPermissions("system:mytongji:edit")
    @Log(title = "客服不满意率统计", businessType = BusinessType.UPDATE)
    @PostMapping("/edit")
    @ResponseBody
    public AjaxResult editSave(QMytongji qMytongji)
    {
        return toAjax(qMytongjiService.updateQMytongji(qMytongji));
    }

    /**
     * 删除客服不满意率统计
     */
    @RequiresPermissions("system:mytongji:remove")
    @Log(title = "客服不满意率统计", businessType = BusinessType.DELETE)
    @PostMapping( "/remove")
    @ResponseBody
    public AjaxResult remove(String ids)
    {
        return toAjax(qMytongjiService.deleteQMytongjiByMyids(ids));
    }
}
